/*
 * register.h
 *
 *  Created on: Feb 4, 2012
 *      Author: Craig Markham
 *		Class:  TCSS 371
 *		Assignment:
 */

#ifndef REGISTER_H_
#define REGISTER_H_

#endif /* REGISTER_H_ */

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#define uchar unsigned char
#define ushort unsigned short

#define REGISTER_COUNT 16
#define $R0 (uchar) 0
#define  $R1 0x1
#define  $R2 0x2
#define  $R3 0x3
#define  $R4 0x4
#define  $R5 0x5
#define  $R6 0x6
#define  $R7 0x7
#define  $R8 0x8
#define  $R9 0x9
#define  $RA 0xA
#define  $RB 0xB
#define  IP0 0xC
#define  IP1 0xD
#define  BP 0xE
#define  SP 0xF

/*
 * =======================================================================================
 * Error implementation
 * =======================================================================================
 */
#define  NOERROR   0x0
#define  NULL_PTR  0x1
#define  ARRAY_OOB 0x2
#define  NULL_VALUE 0x3
#define  RESERVED4 0x4
#define  RESERVED5 0x5
#define  RESERVED6 0x6
#define  RESERVED7 0x7
#define  RESERVED8 0x8
#define  RESERVED9 0x9
#define  RESERVED10 0xA
#define  RESERVED11 0xB
#define  RESERVED12 0xC
#define  RESERVED13 0xD
#define  RESERVED14 0xE
#define  RESERVED15 0xF

/*
 * =======================================================================================
 * Register implementation
 * =======================================================================================
 */

typedef unsigned short Register;
typedef Register * RegisterPtr;

void register_init(RegisterPtr);

int register_putRegValue(RegisterPtr, ushort);

int register_putLowByte(RegisterPtr, uchar);

int register_putHighByte(RegisterPtr, uchar);

int register_getRegValue(RegisterPtr, int);

uchar register_getLowByte(RegisterPtr, int *);

uchar register_getHighByte(RegisterPtr, int *);

int register_signOf(RegisterPtr);

